home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
fullpath.arc
/
FULLPATH.C
next >
Wrap
Text File
|
1986-06-04
|
2KB
|
71 lines
#include <stdio.h>
#include <dos.h>
#include <string.h>
char *
fullpath(s)
char *s;
{
static char buf[FMSIZE*2];
extern char _SLASH;
char *p, *ld;
if (s == NULL)
return(NULL);
if ((*s >= 'A' && *s <= 'Z' || *s >= 'a' && *s <= 'z') && s[1] == ':')
{
buf[0]= *s|' ';
s += 2;
} else
buf[0]=getdsk()+'a';
buf[1]=':';
p = &buf[2];
if (*s != _SLASH)
{
p[0]=_SLASH;
getcd(buf[0]-'a'+1, &p[1]);
p = &buf[strlen(buf)];
if (p[-1] != _SLASH)
*p++ = _SLASH;
}
strcpy(p, s);
for(p=buf ; *p ;)
if (*p >= 'A' && *p <= 'Z')
*p++ |= ' ';
else
if (*p == _SLASH)
if (p[1] == _SLASH || p[1] == '\0' && p != &buf[2])
strcpy(p, &p[1]);
else
if (p[1] == '.')
{
for(ld=p ; --ld > buf ;)
if (*ld == _SLASH)
break;
if (!(ld > buf))
ld=p;
if (p[2] == '.')
if (p[3] == _SLASH)
{
strcpy(ld, &p[3]);
p=ld;
} else
if (p[3] == '\0')
(p=ld)[1]='\0';
else
p++;
else
if (p[2] == _SLASH)
strcpy(&p[1], &p[3]);
else
if (p[2] == '\0')
p[1]='\0';
else
p++;
} else
p++;
else
p++;
return(buf);
}